import {ref, computed} from 'vue'
import {defineStore} from 'pinia'

export const useCounterStore = defineStore('counter', () => {
    const list = [
        {
            value: 1,
            text: "分类管理",
            path: '/classification',
            children: [
                {
                    text: '查看分类',
                    name: 'classification_table'
                },
                {
                    text: '添加分类',
                    name: 'classification_form'
                }
            ]
        },
        {
            value: 2,
            text: "库存管理",
            path: '/inventory',
            children: [
                {
                    text: '查看库存',
                    name: 'inventory_table'
                },
                {
                    text: '添加商品',
                    name: 'inventory_form'
                }
            ]
        }, {
            value: 3,
            text: "入库管理",
            path: '/enterStore',
            children: [
                {
                    text: '入库管理',
                    name: 'enterStore_table'
                },
                {
                    text: '商品入库',
                    name: 'enterStore_form'
                }
            ]
        }, {
            value: 4,
            text: "预警管理",
            path: '/earlyWarning',
            children: [
                {
                    text: '预警管理',
                    name: 'earlyWarning_table'
                },
                {
                    text: '添加预警',
                    name: 'earlyWarning_form'
                }
            ]
        },
        {
            value: 5,
            text: "出库管理",
            path: '/leaveStore',
            children: [
                {
                    text: '出库汇总',
                    name: 'leaveStore_table'
                },
                {
                    text: '销售配送单',
                    name: 'leaveStore_form'
                },
                {
                    text: '损耗出库',
                    name: 'wastage_form'
                }
            ]
        },
        {
            value: 6,
            text: "客户管理",
            path: '/user',
            children: [
                {
                    text: '查看客户',
                    name: 'user_table'
                },
                {
                    text: '添加客户',
                    name: 'user_form'
                }
            ]
        },
        {
            value: 7,
            text:"单价管理",
            path: '/price',
            children: [
                {
                    text: '查看单价',
                    name: 'price_table'
                },
                {
                    text: '添加单价',
                    name: 'price_form'
                }
            ]
        }
    ]
    const token = ref(null)
    const isLogin = ref(0)
    const getIsWarn=ref(0)
    const userName=ref("")
    return {
        list,
        token,
        isLogin,
        getIsWarn,
        userName
    }
}, {
    persist: [
        {
            storage: sessionStorage,
            paths: ["isLogin"]
        },
        {
            storage: localStorage,
            paths: ['token','userName']
        }
    ]
})
